/**
 * @file   ValueInfo.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2013-05-19
 * @brief  DataBus Value Info.
 *
 * Copyright (C) 2013  Djuro Drljaca <djurodrljaca@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIBDATABUS_COMMON_VALUEINFO_H
#define LIBDATABUS_COMMON_VALUEINFO_H

#include <QtCore/QString>
#include <DataBus/Common/Common.h>

namespace DataBus
{
/**
 * @brief The ValueInfo class
 */
class DATABUSSHARED_EXPORT ValueInfo
{
public:
    /**
     * @brief Constructor for ValueInfo
     */
    ValueInfo();

    /**
     * @brief Constructor for ValueInfo
     *
     * @param dataType  Value Data Type
     * @param name      Value Name
     */
    ValueInfo(const DataType dataType,
                  const QString &name);

    /**
     * @brief Copy constructor for ValueInfo
     *
     * @param copyin    Original value
     */
    ValueInfo(const ValueInfo &copyin);

    /**
     * @brief Operator =
     *
     * @param rhs   Value on the right side of the operator =
     *
     * @return Value Info
     */
    ValueInfo & operator=(const ValueInfo &rhs);

    /**
     * @brief Check if Value Info is valid
     *
     * @retval true     Value Info is valid
     * @retval false    Value Info is invalid
     */
    bool isValid() const;

    /**
     * @brief Get Value Data Type
     *
     * @return Data Type
     */
    DataType getDataType() const;

    /**
     * @brief Set Value Data Type
     *
     * @param dataType  Value Data Type
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setDataType(const DataType dataType);

    /**
     * @brief Get Value Name
     *
     * @return Value Name
     */
    QString getName() const;

    /**
     * @brief Set Value Name
     *
     * @param name  Value Name
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setName(const QString &name);

    /**
     * @brief Convert Value Info to binary (byte array)
     *
     * @return Byte array with binary representation of Value Info
     */
    QByteArray toBinary() const;

    /**
     * @brief Parse Value Info from binary (byte array)
     *
     * @param data              Binary data
     * @param startIndex        Start index of binary data
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool fromBinary(const QByteArray &data,
                    const int startIndex = 0);

private:
    /**
     * @brief Value Data Type
     */
    DataType m_dataType;

    /**
     * @brief Value Name
     */
    QString m_name;
};
}

#endif // LIBDATABUS_COMMON_VALUEINFO_H
